$(document).ready(function () {
    $('.kbarcode').kendoBarcode({
        value: $('.kbarcode').attr('codeforbar'),
        type: "code128",
        width: 400,
        height: 60,
        text: {
            color: "black",
            font: "15px Consolas, Monaco, Sans Mono, monospace, sans-serif !important",
            margin: {
                left: -50
            }
        }
    });
    $('.qrcode').kendoQRCode({
        value: $('.qrcode').attr('code'),
        size: 100,
        color: $('.qrcode').attr('color'),
        background: "transparent"
    });
    var date = $('#dateExp>p').data('date');
    $('#dateExp>p').append(' ' + kendo.toString(new Date(date.replace(/-/g, "/")), "D"));

    $('#exportPDF').on('click', function() {
        $('#backDiploma').css('display', 'block');
        getPDF();
    });
});

function getPDF() {
    kendo.drawing.drawDOM($("#toExport"), { forcePageBreak: ".page-break" })
        .then(function(group) {
            // Render the result as a PDF file
            return kendo.drawing.exportPDF(group, {
                paperSize: "letter",
                landscape: 'landscape',
                margin: { left: "1cm", top: "1cm", right: "1cm", bottom: "1cm" }
            });
        })
        .done(function(data) {
            // Save the PDF file
            kendo.saveAs({
                dataURI: data,
                fileName: "Diploma.pdf",
                proxyURL: "http://demos.telerik.com/kendo-ui/service/export"
            });
            $('#backDiploma').css('display', 'none');
        });
}